<template>
  <view class="dynamic-state-root" :style="fullStyle">
    <!-- 详情 begin -->
    <view class="content-item-1">
      <image :src="dynamicStateInfo.newsCover"></image>
      <dynamic-info :dynamic-state-info="dynamicStateInfo"></dynamic-info>
      <view class="text-content-container text-content">
        {{ dynamicStateInfo.newsContent }}
      </view>
    </view>
  </view>
</template>

<script>
import {getFileAccessHttpUrl} from "@/until/fileUtil";
import dynamicInfo from '@/compontent/dynamicInfo'
import {requestGet} from "@/until/means/request";
import {baseMixins} from "@/mixins/baseMixins";
import {getApiByName} from '@/api/contact'
import {baseFilePath} from "@/until/publicConfig";
import {formtimestamp, friendlyDate} from "@/until/timeUtil";
export default {
  components: {dynamicInfo},
  mixins: [baseMixins],
  data() {
    return {
      dynamicStateInfo: {},
      infoQueryUrl: '',
      newsId: '',
    };
  },
  onLoad(params) {
    this.infoQueryUrl = getApiByName(params.infoQueryUrl)
    this.newsId = params.newsId
    this.queryIdName = params.queryIdName
    this.getInfoData()
  },
  methods: {
    getInfoData() {
      let {newsId, infoQueryUrl: url, queryIdName} = this
      requestGet({url, data: {[queryIdName]: newsId}}).then(res => {
        let item = res
		
		item.newsCover = item.newsCover != null && item.newsCover != '' ? getFileAccessHttpUrl(item.newsCover) : `${baseFilePath}/home/news-1.png`
		item.publishTime = item.publishTime != null && item.publishTime !== '' ? friendlyDate(formtimestamp(item.publishTime)) : ''
	
		item.queryIdName = queryIdName
		
		this.dynamicStateInfo = item
       // this.dynamicStateInfo.newsCover = getFileAccessHttpUrl(this.dynamicStateInfo.newsCover)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.dynamic-state-root {
  padding: 0 30rpx;
  color: #222222;
  box-sizing: border-box;
  overflow: auto;

  .content-item-1 {
    display: flex;
    flex-direction: column;
    height: auto;
    background-color: $bg-color-white;
    padding-top: 30rpx;
    font-size: $font-size-medium;
    border-radius: 30rpx;
    margin-bottom: 30rpx;

    image {
      border-radius: 30rpx 30rpx 0 0;
      width: calc(100% - 40rpx);
      margin: 0 20rpx;
      height: 360rpx;
    }

    .text-content-container {
      border-top: 1rpx solid #C7C7C7;
      padding-top: 30rpx;
      margin: 0 30rpx 30rpx 30rpx;
    }
  }

}


</style>
